/**
 * type: 微信活动
 * des：用户报名.
 * by: Xie Xiaofei
 * created: 2017/2/14
 * lastupdate: 2017/7/7 
 * 
 * url: /checkin
 * method: post
 * body: projName name phone remark
 * return: {code}    // 1更新 2插入
 */


var path = require('path')
var routerApi = require('../../utils/routeString.js')(__filename, __dirname);
var utils = require('../../utils/index.js')
var validate = utils.validate;
var ip = utils.ip;
var SqlHelper = utils.SqlHelper;

server.post({ path: routerApi, name: routerApi }, function (req, res, next) {
    var body = req.body;

    if (!validate.isName(body.name) || !validate.isPhone(body.phone)) {
        res.send({ code: 0, msg: '参数错误!' });
        return next();
    }

    var data = {
        name: body.name,
        phone: body.phone
    }

    var sqlHelper = new SqlHelper('checkin');
    sqlHelper.pushData(data, data, (state, results) => {
        res.send({ code: state });
        return next();
    })

})
